package io.github.cubelitblade.librarymanagementbackend.utils;

import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
public enum BusinessStatus {
    // 普通业务成功
    BUSINESS_SUCCESS(0, HttpStatus.OK),

    // 普通业务失败
    BUSINESS_FAILURE(1000, HttpStatus.INTERNAL_SERVER_ERROR),

    // 接口暂未实现
    NOT_IMPLEMENTED(1001, HttpStatus.NOT_IMPLEMENTED),

    // 数据库异常
    DATABASE_ERROR(1002, HttpStatus.INTERNAL_SERVER_ERROR),

    // 用户已经存在（用于注册）
    USER_ALREADY_EXIST(2001, HttpStatus.CONFLICT),

    // 用户不存在（用于登录或者查找用户）
    USER_NOT_FOUND(2002, HttpStatus.NOT_FOUND),

    // 密码错误（用于登录）
    PASSWORD_INCORRECT(2003, HttpStatus.UNAUTHORIZED),

    // 关键字段为空（用于注册或登录）
    NULL_KEY_FIELD(2004, HttpStatus.BAD_REQUEST),

    // 未登录（用于前端加载时检测登录状态）
    UNAUTHORIZED(2005, HttpStatus.UNAUTHORIZED),

    // 会话过期（用于前端加载时检测登录状态）
    SESSION_EXPIRED(2006, HttpStatus.UNAUTHORIZED),

    // 书籍不存在
    BOOK_NOT_FOUND(3001, HttpStatus.NOT_FOUND),

    // 书籍没有剩余
    BOOK_OUT_OF_STOCK(3002, HttpStatus.CONFLICT),

    // 书籍量溢出
    BOOK_STOCK_OVERFLOW(3007, HttpStatus.CONFLICT),

    // 找不到借阅记录
    BORROW_RECORD_NOT_FOUND(3003, HttpStatus.NOT_FOUND),

    // 借阅状态异常
    BORROW_RECORD_STATUS_CONFLICT(3004, HttpStatus.CONFLICT),

    // 找不到收藏记录
    FAVORITE_RECORD_NOT_FOUND(3005, HttpStatus.NOT_FOUND),

    // 收藏状态异常
    FAVORITE_RECORD_STATUS_CONFLICT(3006, HttpStatus.CONFLICT);

    private final int businessStatusCode;
    private final HttpStatus httpStatusCode;

    BusinessStatus(int businessStatusCode, HttpStatus httpStatusCode) {
        this.businessStatusCode = businessStatusCode;
        this.httpStatusCode = httpStatusCode;
    }
}
